package com.byl.modules.attachment;

import com.byl.common.modules.controller.BaseController;
import com.byl.sdk.poi.WordToHtml;
import com.byl.sdk.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2019/12/29.
 */
@RestController
@RequestMapping("/poi")
public class PoiController extends BaseController {

    @Value("${spring.serverurl}")
    String serverurl;

    @PostMapping("/word")
    public String word(HttpServletRequest request, @RequestPart MultipartFile file){
        String path= UploadUtils.uploadFile(request,"word",file);
        String data= WordToHtml.readDoc(request,path,serverurl);
        data=data.replaceAll("&rdquo;","\\\"").replaceAll("&ldquo;","\\\"");
        Map map=new HashMap();
        map.put("path",path);
        map.put("data",data);
        return success("读取word",map);
    }
}
